package com.xiaobange.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaobange.dto.GeneralPageParam;
import com.xiaobange.entity.Medicine;
import com.xiaobange.service.MedicineService;
import com.xiaobange.mapper.MedicineMapper;
import org.springframework.stereotype.Service;

/**
* @author banji
* @description 针对表【medicine(药品表)】的数据库操作Service实现
* @createDate 2025-04-24 17:57:21
*/
@Service
public class MedicineServiceImpl extends ServiceImpl<MedicineMapper, Medicine>
    implements MedicineService{

    /**
     * 分页查询
     * @param generalPageParam 分页参数
     * @return
     */
    @Override
    public Page<Medicine> queryPage(GeneralPageParam generalPageParam ) {
        Page<Medicine> medicinePage = new Page<>();
        medicinePage.setCurrent(generalPageParam.getCurrent());
        medicinePage.setSize(generalPageParam.getSize());
        LambdaQueryWrapper<Medicine> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(!generalPageParam.getSearchQuery1().isEmpty(),Medicine::getBarCode,generalPageParam.getSearchQuery1())
                .or()
                .like(!generalPageParam.getSearchQuery1().isEmpty(),Medicine::getName,generalPageParam.getSearchQuery1())
                .or()
                .like(!generalPageParam.getSearchQuery1().isEmpty(),Medicine::getDescription,generalPageParam.getSearchQuery1());
        Page<Medicine> page = this.page(medicinePage, wrapper);
        return page;
    }
}




